//
// Created by TNJ on 2021/6/10.
//

#ifndef QUEUE_QUEUE_H
#define QUEUE_QUEUE_H

#include <stdbool.h>

#define NAN (0xFFFFFE)

typedef struct node{
    int data;
    struct node *next;
}node_t;

typedef struct queue{
    node_t *head;
    node_t *tail;
}queue_t;

extern void queue_init(queue_t *q);  //队列初始化
extern void enqueue(queue_t *q, int data);  //数据入队
extern int dequeue(queue_t *q);  //数据出队列
extern int queue_length(queue_t *q);  //获取队列长度
extern void queue_destroy(queue_t *q);  //销毁队列

typedef struct queue_arr{
    int head;
    int tail;
    int cap;
    int size;
    int *arr;
}queue_arr_t;
extern void queue_arr_init(queue_arr_t *q, int capacity);  //队列初始化
extern void enqueue_arr(queue_arr_t *q, int data);  //入队
extern int dequeue_arr(queue_arr_t *q);  //出队
extern void queue_arr_destroy(queue_arr_t *q);  //销毁队列
extern bool queue_arr_is_full(queue_arr_t *q);  //判断队列是否满
extern bool queue_arr_is_empty(queue_arr_t *q);  //判断队列是否为空
extern int queue_arr_length(queue_arr_t *q);  //获取队列长度


#endif //QUEUE_QUEUE_H
